package com.eryos.android.cigarettecounter.charts;

/**
 * Project :  CigaretteCounter
 * Author :   Olivier Combe 
 * URL :      http://eryos.fr/CigaretteCounter/
 *
 * Copyright (C) 2011 - Olivier Combe 
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 *
 */

import java.util.ArrayList;



public class HistoChart extends Chart {

	int maxVal = 12;
	int YMaxRange = Math.round(new Float(1.2*maxVal));
	int YMinRange = 0;
	int nbValue = 6;
	
	String barColor = "A2C180";
	String YAxisLabel = "";
	
	ArrayList<Integer> values;
	
	public HistoChart() {
		type 		= "bvg";
	}
	
	public void generateURL(){    	

		String gTitle = "";
		String gTitleFont = "";
		String gBackground 	= "chf=bg,s,"+bgColor;
		String gXLabel 		= "&chxl=1:|"+YAxisLabel;
		String gScale 		= "&chxr=0,0,"+YMaxRange;
		String gLegendColor = "&chxs=0,"+axisColor+","+textSize+",0,l,"+axisColor+"|1,"+axisColor+","+textSize+",0,l,"+axisColor+"";
		String gVisibleAxis = "&chxt=y,x";
		String gUnknown2 	= "&chbh=a,5,10";
		String gSize 		= "&chs="+width+"x"+height;
		String gChartType 	= "&cht="+type;
		String gDataColor 	= "&chco="+barColor;
		String gMaxYValue 	= "&chds=0,"+YMaxRange;
		String gData 		= "&chd=t:"+data;
		String gLegend 		= "&chdlp=t";
		String gUnknown1 	= "&chg=0,10";
		String gValueLegend = "&chm=N,ffffff,0,,10";
		
		if ( title != null ){
			gTitle 		= "&chtt="+title.replaceAll(" ", "+");
			gTitleFont 	= "&chts="+titleColor+","+titleSize;		
		}
		//&chm=N,000000,0,,10|N,000000,1,,10|N,000000,2,,10
		//&chm=SERIE_1|SERIE_2|SERIE_3
		//&chm=N,font_color,serie_number,,font_sze

		
		URL = ROOT_URL +
		gBackground  +
		gXLabel  +
		gScale  +
		gLegendColor  +
		gVisibleAxis  +
		gUnknown2  +
		gSize  +
		gChartType  +
		gDataColor  +
		gMaxYValue  +
		gData  +
		gLegend  +
		gUnknown1  +
		gTitle +
		gTitleFont +
		gValueLegend; 
	}



	public int getMaxVal() {
		return maxVal;
	}



	public void setMaxVal(int maxVal) {
		this.maxVal = maxVal;
		YMaxRange = Math.round(new Float(1.2*maxVal));
	}



	public String getBarColor() {
		return barColor;
	}



	public void setBarColor(String barColor) {
		this.barColor = barColor;
	}



	public String getYAxisLabel() {
		return YAxisLabel;
	}



	public void setYAxisLabel(String _yAxisLabel) {
    	if ( _yAxisLabel.length() > Chart.LABEL_SEPARATOR.length() && _yAxisLabel.endsWith(LABEL_SEPARATOR) )
    		_yAxisLabel = _yAxisLabel.substring(0, _yAxisLabel.length()- Chart.LABEL_SEPARATOR.length());
		
		YAxisLabel = _yAxisLabel;
	}



	public ArrayList<Integer> getValues() {
		return values;
	}



	public void setValues(ArrayList<Integer> values) {
		this.values = values;
	}

	
		
	
}
